home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Utilities / Communications / Pancake Dev Package 1.0 / PancakeCommon.p < prev    next >
Encoding:
Text File  |  1995-09-05  |  17.8 KB  |  605 lines  |  [TEXT/PJMM]

  1. unit PancakeCommon;
  2. interface
  3. {$IFC MWerks}
  4.     uses
  5.         Types, Files, Windows, Menus, Memory, Dialogs, Fonts, TextUtils, Packages;
  6. {$ENDC}
  7.  
  8.     const
  9.         Keypad = 'ABCDEFGHIJKLMNOPRSTUVWXY';
  10.         PossTypeable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-_+={}[]:;"<,>.?/|\~` ''éå∫ç∂´ƒ©˙^Δ˚¬µøπœ®ß†¨√∑≈¥ΩÅıÇΉÏÌÓÈÔÒ˜ˆØ∏ŒÂÍÊË◊„ÙÁÛ¡™£¢∞§¶•ªº–≠⁄€‹›fifl‡°·‚—±”’“‘ÚÆ…æ≤≥¯˘÷¿»«Ÿ';
  11.         PossPrintable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-_+={}[]:;"<,>.?/|\~` ''';
  12.         PossUsername = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
  13.         PossPhone = '1234567890-';
  14.         MacJmp = $120;          {[PTR2LONG]}
  15.         TabEqualsSpace = false;
  16.         InputBufSize = 512;
  17.         ModGeneva = 128;
  18.         IBMCharset = 129;
  19.         BoldIBMCharset = 130;
  20.         Creator = 'Cake';
  21.         UserType = 'User';
  22.         PrefType = 'Pref';
  23.         DataType = 'DATA';
  24.         ExternType = 'XPan';
  25.         TextType = 'TEXT';
  26.         Version = '1.0';
  27.         Null = chr(0);
  28.         EscCode = chr(1);
  29.         ControlC = chr(3);
  30.         BackSpace = chr(8);
  31.         Tab = chr(9);
  32.         Linefeed = chr(10);
  33.         Return = chr(13);
  34.         CntrlX = chr(24);
  35.         Escape = chr(27);
  36.         Destructive = chr(127);
  37.         tooManyNodesErr = -13542;
  38.         MaxNodes = 22; {Normally 22}
  39.         MaxPorts = 3; {Normally 3}
  40.         MaxMenus = 20;
  41.         EditTextStart = 1;        {Window Types}
  42.         EditTextEnd = 10;
  43.         UserEdit = 11;
  44.         GroupEdit = 12;
  45.         StringEdit = 13;
  46.         PortPrefs = 14;
  47.         SysPrefs = 15;
  48.         ScreenSaver = 16;
  49.         AboutBox = 17;
  50.         BoardStatus = 18;
  51.         PortStatus = 19;
  52.         Diagnostic = 20;
  53.         MenuEdit = 21;
  54.         NodeStart = 100;
  55.         NodeEnd = NodeStart + MaxNodes;
  56.         ScrollBackLines = 250;
  57.         MaxX = 80;
  58.         MaxY = 24;
  59.         IncX = 6;
  60.         IncY = 11;
  61.         MemBuffer = 61440;
  62.         InitExt = 1;
  63.         Idle = 2;
  64.         KeyPressed = 3;
  65.         DisposeExt = 4;
  66.         DisposeGlobal = 5;
  67.  
  68.     type
  69.         str16 = string[16];
  70.         str8 = string[8];
  71.         systemRec = record
  72.                 version, numUsers, numGroups, numCookies, numPorts, logMain, callsToday: integer;
  73.                 maxPageCalls, maxPageSegments, maxPageDigits, windowsOpen, validPaths: integer;
  74.                 lastCaller, NUP: str16;
  75.                 checkNUP, unusedUseMe, speakReason, excuseBefore, sysopAvail, pagingOn, encodeLetters: boolean;
  76.                 postLocally: boolean;
  77.                 portStatusRect, boardStatusRect: rect;
  78.                 pageAcs, netPostAcs: string[25];
  79.                 pagerPhone: string[41];
  80.                 uucpNode: str16;
  81.                 timezone: string[5];
  82.                 curDay, curMonth, lastCall: longint;
  83.                 organization, newsFrom, domainName: string[59];
  84.                 paths: array[1..8] of string[127];
  85.                 uucpPort, suckerPort, termPort: integer;
  86.                 spoolPath, slurpSpoolPath, mailPath: string[127];
  87.                 localPass: str16;
  88.                 localProtection, uucpMail: boolean;
  89.                 mailService: str16;
  90.                 receiveMailAcs, sendMailAcs: string[25];
  91.                 seqf: integer;
  92.                 mailFrom: string[59];
  93.                 saverEnabled: boolean;
  94.                 saverIdle: integer;
  95.                 checkPopMail, smtpServerEnabled, smtpMail: boolean;
  96.                 popServer, smtpRelay: str31;
  97.                 uucpKickUsers, strictPhone: boolean;
  98.                 uucpLaunchEvery: integer;
  99.                 uucpLaunchedLast: longint;
  100.                 phoneFormat: str31;
  101.                 uucp, uucpFile, parser, term, sucker: FSSpec;
  102.                 bbsName: str31;
  103.                 suckerKickUsers: boolean;
  104.                 suckerLaunchEvery: integer;
  105.                 suckerLaunchedLast: longint;
  106.                 telnetAcs, fingerOutAcs: string[25];
  107.                 pppPort: integer;
  108.                 pppEnable, pppOpen, pppClose, pppHard: boolean;
  109.                 chatSound, sosSound: str32;
  110.                 printAcs, chatAcs, sosAcs: string[25];
  111.                 numMenus: integer;
  112.                 redirectAcs: string[25];
  113.                 passwordsEcho, hotkeyMenuFirst: boolean;
  114.             end;
  115.         asyncWritePtr = ^asyncWriteRec;
  116.         asyncWriteRec = record
  117.                 pb: ParamBlockRec;
  118.                 nextPtr: asyncWritePtr;
  119.                 data: packed array[1..32000] of byte;
  120.             end;
  121.         carrierType = (NoDetection, Bob, CTS, DCDchip, DCDdriver);
  122.         portType = (Serial, TCP, AppleTalk, SysopLocal);
  123.         portSavRec = record
  124.                 nodeRect: rect;
  125.                 timeout, maxConns: integer;
  126.                 connAcs: string[25];
  127.                 callSound: str32;
  128.                 res: packed array[1..255] of byte;
  129.                 case typePort : portType of
  130.                     Serial: (
  131.                             typeCarrier: CarrierType;
  132.                             baud: longint;
  133.                             modemDriver, serialPort: integer;
  134.                             hwHand, pageable: boolean;
  135.                             res1: packed array[1..255] of byte;
  136.                     );
  137.                     TCP: (
  138.                             tcpPort: integer;
  139.                             enableFinger: boolean;
  140.                             res2: packed array[1..255] of byte;
  141.                     );
  142.                     AppleTalk: (
  143.                             adspName: str32;
  144.                             res3: packed array[1..255] of byte;
  145.                     );
  146.             end;
  147.         portGlobRec = record
  148.                 sessions, openPort, oldStatusLen: integer;
  149.                 lastInit: longint;
  150.                 connectionLost, inUse: boolean;
  151.                 status: string[80];
  152.                 case portType of
  153.                     Serial: (
  154.                             modemSection: (Hangup, InitSerial, PortIsBad, PortIsBusy, Offline, InitModem, GetOk, Awaiting, Answering);
  155.                             modemRedirecting: boolean;
  156.                             inRefnum, outRefnum: integer;
  157.                             inputBuffer: ptr;
  158.                             topWritePtr: asyncWritePtr;
  159.                     );
  160.                     TCP: (
  161.                             tcpSection: (InitTCP, GotError, AwaitingOpen, Connecting, CloseConn);
  162.                             fingerInSection: (OpenFingerIn, GotFingerErr, WaitingForFinger, NeedName, SendFingerInfo, CloseFingerIn);
  163.                             curTcpRefnum, fingerRefnum: integer;
  164.                             fingerName: string[80];
  165.                     );
  166.                     AppleTalk: (
  167.                             atlkSection: (InitAtlk, GotAtlkError, AwaitingAtlkOpen, AtlkConnecting, AtlkCloseConn);
  168.                             clConnRefnum, curConnRefnum: integer;
  169.                     );
  170.             end;
  171.         boardGlobRec = record
  172.                 done, screenSaverUp, inBackground, uucpLoaded, termLoaded, pageQueued, localLocked: boolean;
  173.                 windowsDirty, menusLocked, lpBeeped, kickingUUCPUsers, kickingSuckerUsers: boolean;
  174.                 suckerLoaded, editingPorts: boolean;
  175.                 lastResRefnum, strResRefnum, sndResRefnum, txtResRefnum, groupCheck, lpPos: integer;
  176.                 groupsStamp, lastIdleMess, gestaltOSAttrResult: longint;
  177.                 addedHotkey: str32;
  178.             end;
  179.         displayPtr = ^displayRec;
  180.         displayRec = record
  181.                 cx, cy, sx, sy, head, tail, linesSincePause, param, scrollMTop, scrollMBot: integer;
  182.                 nodeWind: WindowPtr;
  183.                 scroll: ControlHandle;
  184.                 lastClick: longint;
  185.                 pasteHand: handle;
  186.                 cursorRect, selRect: rect;
  187.                 params: array[1..5] of byte;
  188.                 reversed, blinkOn, inScrollBack, inEsc, questMark: boolean;
  189.                 afterEsc: (OpenBracket, OpenParanth, CloseParanth);
  190.                 screen: packed array[1..MaxY, 0..MaxX] of byte;
  191.                 scrollback: packed array[1..ScrollBackLines, 0..MaxX] of byte;
  192.             end;
  193.         joinRec = record
  194.                 groupHash, numRead: longint;
  195.             end;
  196.         joinHand = ^joinPtr;
  197.         joinPtr = ^joinArr;
  198.         joinArr = array[1..32768] of joinRec;
  199.  
  200.         userRecPtr = ^userRec;
  201.         userRec = record
  202.                 userName, password: str16;
  203.                 shell, localEdit, remoteEdit: str8;
  204.                 name, phone: string[32];
  205.                 timeOnToday, extraTime, firstLogin, previousLogin, upload, download: longint;
  206.                 minsPerDay, userNum: integer;
  207.                 accessLevel, priv, linesPerPage: byte;
  208.                 male: boolean;
  209.                 birthday: longint;
  210.                 comment: string;
  211.                 emulation: (tty, vt100, ansi, tek, rip);
  212.                 checkPop: boolean;
  213.                 selGroup: integer;
  214.                 res: packed array[1..37] of byte;
  215.             end;
  216.  
  217.         mailIndexRec = record
  218.                 loc, len: longint;
  219.                 deleted: boolean;
  220.                 priv: packed array[1..25] of byte;
  221.             end;
  222.         mailIndexHand = ^mailIndexPtr;
  223.         mailIndexPtr = ^mailIndexArr;
  224.         mailIndexArr = array[1..32768] of mailIndexRec;
  225.  
  226.         shellType = (Waffle, Hotkey, Other);
  227.         nodeActionType = (None, Prompting, Listing, Chatting, LineChatting, Transfering, Editor, Extern, Menu);
  228.         nodeSectionType = (Shell, Logon, NewUser, ListingUsers, Feedback, Mailing, ReadingMail, Chat, Select, Rn, Post, Join, Finger, Telnet, Page, ChangeShell, ChangeEdit, Edit, AreYouSure, Help, Redirect, OneLiner, MultiChat, Download);
  229.         nodeGlobPtr = ^nodeGlobRec;
  230.         nodeGlobRec = record
  231.                 display: displayRec;
  232.                 keyBuf, userKeyBuf: string;
  233.                 curTextHand: Handle;
  234.                 nodeAction: nodeActionType;
  235.                 yesDefault, critical, nodeClosing, abortListing, pauseEnabled, resolveTextPercents: boolean;
  236.                 noReturn, useUserkeyBuf, transInProgress: boolean;
  237.                 typeConn: portType;
  238.                 lenPrompt, numPrompt, curEditor, curExtern, curNum, lenChat, portNum, connRefnum: integer;
  239.                 timesCritical, transRefnum, editRefnum, externRefnum: integer;
  240.                 curTextPos, curTextSize, loginTime, lastKeypress, lastBlink, textStart: longint;
  241.                 cps, maxPrompt: longint;
  242.                 promptProc, quitHandlerProc: ProcPtr;
  243.                 thisUser: userRec;
  244.                 curPath, curPrompt, curAnswer, curCommand, curParams, shellPrompt, pauseAccepted, interNode: string;
  245.                 numParams, curMenu, shellMenu: integer;
  246.                 savedNodeAction: array[1..4] of nodeActionType;
  247.                 whichShell: ShellType;
  248.                 specialPrompt: (Normal, Command, Password, WordWrap);
  249.                 shellSection: (InitShell, BeforePrompt, MainPrompt, BeforeGo, GoSection);
  250.                 sysopPos, userPos: point;
  251.                 savedUseUserKeyBuf, inSlash: boolean;
  252.                 joinData: joinHand;
  253.                 mailIndex: mailIndexHand;
  254.                 curChat, curSysChat: string[80];
  255.                 savedVarient: ptr;
  256.                 subject: string[80];
  257.                 case nodeSection : NodeSectionType of
  258.                     Logon: (
  259.                             logonSection: (Welcome, NamePrompt, PassPrompt, CheckInfo, LogonFile, CheckBulletins, CheckMail, ToShell);
  260.                             lvRefnum, logonIndex: integer;
  261.                             lDirID: longint;
  262.                     );
  263.                     NewUser: (
  264.                             newUserSection: (NUPText, NUPPrompt, CheckNup, AccessCode, CheckCode, NewUserText, NewUserName, NewName, NewPhone, NewBirth, NewSex, NewPassword, VerifyPassword, SaveUserInfo);
  265.                             question: boolean;
  266.                     );
  267.                     ListingUsers: (
  268.                             curUser: integer;
  269.                             loadedUser: userRec;
  270.                     );
  271.                     Feedback: (
  272.                             feedbackSection: (FeedbackText, FeedbackPrompt, SendFeedback);
  273.                     );
  274.                     Mailing: (
  275.                             mailingSection: (ReplyMail, WhoTo, MailSubject, MailEdit, SaveMail);
  276.                             curMailing: str16;
  277.                             curDomainAddr: string[80];
  278.                     );
  279.                     ReadingMail: (
  280.                             rmSection: (InitRm, RmPrompt, RmProcess, ListRm, CloseRm);
  281.                             rmRefnum, numMail, curMail, rmTi: integer;
  282.                     );
  283.                     Chat: (
  284.                             chatSection: (ChatText, ChatYesNo, ReasonPrompt, Beep);
  285.                     );
  286.                     Select: (
  287.                             selectSection: (AskGroup, SelectAction);
  288.                     );
  289.                     Rn, Post: (
  290.                             rnSection: (InitRn, CheckGroup, AskRead, ProcessAnswer, ReadMessage, RnPrompt, RnAction, RnSecond, ListingTitles, InitSearch, Searching, Posting, CatchUp, RnWriting, RnBatchWrite, CloseRn);
  291.                             curGroup: integer;
  292.                             search: string[40];
  293.                             references: string;
  294.                             curMess, curPost, rnTli: longint;
  295.                             read, searchForward: boolean;
  296.                             case integer of
  297.                                 1: (
  298.                                         batchWriteSection: (BWCheck, BWFilenameP, BWInit, PerformBW);
  299.                                         bwFrom, bwTo: longint;
  300.                                 );
  301.                                 2: (
  302.                                         postingSection: (PostReply, PostSubject, PostEdit, SavePost);
  303.                                         postSection: (PostCommandline, GroupAction, InitPost, DoingPost, ClosePost);
  304.                                 );
  305.                     );
  306.                     Join: (
  307.                             joinSection: (JoinCommandline, InitJoin, ListGroups, ListingGroups, JoinReturn, JoinPrompt, JoinAction, CloseJoin);
  308.                             joinGroup, joinNum: integer;
  309.                             joining: boolean;  {Joining or unjoining?}
  310.                     );
  311.                     Finger: (
  312.                             FingerSection: (InitFinger, ConnFinger, ConnectingFinger, DoingFinger, CloseFinger);
  313.                             fingerConn: integer;
  314.                             fingerBuf: handle;
  315.                     );
  316.                     Telnet: (
  317.                             TelnetSection: (InitTelnet, ConnTelnet, ConnectingTelnet, DoingTelnet, CloseTelnet);
  318.                             teln: record
  319.                                     conn: integer;
  320.                                     buf, expectBuf: handle;
  321.                                     inOption: boolean;
  322.                                     port, curParam: integer;
  323.                                     status: longint;
  324.                                     option: string[2];
  325.                                 end;
  326.                     );
  327.                     Page: (
  328.                             pageSection: (PageText, PagePrompt, SendPage);
  329.                     );
  330.                     AreYouSure: (
  331.                             sureSection: (AskSure, CheckAndExec);
  332.                             sureType: (OffAYS, LoginAYS);
  333.                     );
  334.                     ChangeShell: (
  335.                             changeShellSection: (CSText, ChangeShellPrompt, SetShell);
  336.                     );
  337.                     ChangeEdit: (
  338.                             changeEditSection: (CEText, ChangeEditPrompt, SetEdit);
  339.                     );
  340.                     Edit: (
  341.                             editSection: (InitEdit, CreateFile, OpenFileEdit, EditFile);
  342.                             editFileRefnum: integer;
  343.                     );
  344.                     Help: (
  345.                             helpSection: (DispMenu, HelpPrompt, PromptAction);
  346.                             helpPath: string[80];
  347.                             helpLevel: integer;
  348.                     );
  349.                     Redirect: (
  350.                             redirectSection: (InitRedirect, DoingRedirect, CleanUpRedirect);
  351.                             redirectPort: integer;
  352.                             lastCntrlX: longint;
  353.                     );
  354.                     OneLiner: (
  355.                             oneLinerSection: (AskNode, CheckNode, AskOneLiner, SendOneLiner);
  356.                             oneLinerNode: integer;
  357.                     );
  358.                     MultiChat: (
  359.                             multiChatSection: (InitMulti, ListMultiUsers, MultiPrompt, DoMulti);
  360.                     );
  361.                     Download: (
  362.                             dlSection: (FilePrompt, DoFind, ProtoPrompt, DoDown);
  363.                     );
  364.             end;
  365.         userIndexRec = record
  366.                 name: str16;
  367.                 num: longint;
  368.             end;
  369.         userIndexHand = ^userIndexPtr;
  370.         userIndexPtr = ^userIndexArr;
  371.         userIndexArr = array[1..32768] of userIndexRec;
  372.  
  373.         typeGroupType = (Local, Usenet, Fidonet);
  374.         groupRec = record
  375.                 groupName: string[58];
  376.                 min, max, lastScan, dirID: longint;
  377.                 validBits, vRefnum, hash, keep: integer;
  378.                 readAcs, postAcs: string[25];
  379.                 typeGroup: typeGroupType;
  380.                 anon, new: boolean;
  381.             end;
  382.         groupHand = ^groupPtr;
  383.         groupPtr = ^groupArr;
  384.         groupArr = array[1..32768] of groupRec;
  385.  
  386.         sectionRec = record
  387.                 sectionName: string[58];
  388.                 lookAcs, dlAcs, ulAcs: string[25];
  389.                 free: boolean;
  390.                 dirID: longint;
  391.                 vRefnum, validityBits: integer;
  392.                 res: packed array[1..42] of byte;
  393.             end;
  394.         sectionHand = ^sectionPtr;
  395.         sectionPtr = ^sectionArr;
  396.         sectionArr = array[1..32768] of sectionRec;
  397.  
  398.         commandsRec = record
  399.                 hotkey: char;
  400.                 slash, enabled: boolean;
  401.                 mainMenu: str32;
  402.                 acs, description: string[25];
  403.             end;
  404.         commandsArr = array[1..32768] of commandsRec;
  405.         commandsHand = ^commandsPtr;
  406.         commandsPtr = ^commandsArr;
  407.  
  408.         menuRec = record
  409.                 menuName: str32;
  410.                 menuPrompt: string;
  411.                 numCommands: integer;
  412.                 commands: commandsHand;
  413.             end;
  414.  
  415.         cookieIndexHand = ^cookieIndexPtr;
  416.         cookieIndexPtr = ^cookieIndexArr;
  417.         cookieIndexArr = array[1..32768] of longint;
  418.  
  419.         modemStrType = (InitStr, ChangeSpeed, HWOn, HWOff, DtrOn, DtrOff, Answer, HangupStr, Quit);
  420.  
  421.         MailQueueHand = ^MailQueuePtr;
  422.         MailQueuePtr = ^MailQueueArr;
  423.         MailTypeType = (STMPClient, STMPServer, POP2);
  424.         MailQueueRec = record
  425.                 connRefnum: integer;
  426.                 stage: (Opening, Commanding, Reading, Done);
  427.                 received: string;
  428.                 case mailType : MailTypeType of
  429.                     STMPClient: (
  430.                             stmpCommand: (Helo, MailCmd, Rcpt, Data, Close);
  431.                             mailHand: handle;
  432.                     );
  433.                     STMPServer: (
  434.                     );
  435.                     POP2: (
  436.                             popCommand: (HeloCmd, ReadCmd, Retr, CloseCmd);
  437.                             userName, password: str16;
  438.                             count, bytesReceived: longint;
  439.                             receiveHand: handle;
  440.                     );
  441.             end;
  442.         MailQueueArr = array[1..100] of MailQueueRec;
  443.  
  444. {Insert All Declerations Here:}
  445.         privatesHand = Handle;
  446. {End of User Declerations}
  447.  
  448.         editParamsPtr = ^editParamsRec;
  449.         editParamsRec = record
  450.                 message: byte;
  451.                 nodeGlobs: nodeGlobPtr;
  452.                 privates, globals: privatesHand;
  453.                 externRefnum, appRefnum: integer;
  454.                 reserved: packed array[1..96] of char;
  455.                 procs: array[1..25] of ProcPtr;
  456.             end;
  457.  
  458. {End of extern common}
  459.  
  460.     var
  461.         mailQueue: MailQueueHand;
  462.         rootPath: string;
  463.         usersRef, cookiesRef, appRefnum, numNodes, curNode, pppOpened: integer;
  464.         userIndex: userIndexHand;
  465.         cookieIndex: cookieIndexHand;
  466.         groups: groupHand;
  467.         system: systemRec;
  468.         portSav: array[1..MaxPorts] of portSavRec;
  469.         portGlobs: array[1..MaxPorts] of portGlobRec;
  470.         nodeGlobPtrs: array[1..MaxNodes] of nodeGlobPtr;
  471.         menus: array[1..MaxMenus] of menuRec;
  472.         nodeGlobs: nodeGlobPtr;
  473.         boardGlobs: boardGlobRec;
  474.         mouseRgn: RgnHandle;
  475.         AppleMenu, FileMenu, FileSubMenu, EditMenu, SysopMenu, SpecialMenu, WindowsMenu: MenuHandle;
  476.         startupTime, startupTicks, lastMoved, lastIdle: longint;
  477.         resolvePercents, noPorts, inThink: boolean;
  478.  
  479.     function s2i (t1: str255): longint;
  480.     function i2s (t1: longint): string;
  481.     function EnoughMemory (size: longint): boolean;
  482.     procedure SetNodeAction (action: NodeActionType);
  483.     procedure RestoreNodeAction;
  484.     procedure Error (fatal: boolean; str: string);
  485.     function Sure (str: string): boolean;
  486.     procedure DumpHand (hand: handle);
  487.  
  488.     function PppUp: OSErr;
  489.     function PppOpen: OSErr;
  490.     function PppClose (hard: boolean): OSErr;
  491.  
  492. implementation
  493.  
  494. {$IFC MWerks}
  495.     function PppUp: OSErr;
  496.     begin
  497.         PPPUp := -1;
  498.     end;
  499.  
  500.     function PppOpen: OSErr;
  501.     begin
  502.         PppOpen := -1;
  503.     end;
  504.  
  505.     function PppClose (hard: boolean): OSErr;
  506.     begin
  507.         PppClose := -1;
  508.     end;
  509. {$ENDC}
  510.  
  511.     function s2i (t1: str255): longint;
  512.         var
  513.             t2: longint;
  514.     begin
  515.         StringToNum(t1, t2);
  516.         s2i := t2
  517.     end;
  518.     function i2s (t1: longint): string;
  519.         var
  520.             t2: str255;
  521.     begin
  522.         NumToString(t1, t2);
  523.         i2s := t2
  524.     end;
  525.  
  526.     function EnoughMemory (size: longint): boolean;
  527.     begin
  528.         if (FreeMem - size > longint(MemBuffer)) then
  529.             EnoughMemory := true
  530.         else if (CompactMem(size + longint(MemBuffer)) - size >= longint(MemBuffer)) then
  531.             EnoughMemory := true
  532.         else
  533.             begin
  534.                 PurgeMem(size);
  535.                 EnoughMemory := (CompactMem(size + longint(MemBuffer)) - size >= longint(MemBuffer));
  536.             end;
  537.     end;
  538.  
  539.     procedure SetNodeAction (action: NodeActionType);
  540.     begin
  541.         with nodeGlobs^ do
  542.             begin
  543.                 savedNodeAction[4] := savedNodeAction[3];
  544.                 savedNodeAction[3] := savedNodeAction[2];
  545.                 savedNodeAction[2] := savedNodeAction[1];
  546.                 savedNodeAction[1] := NodeAction;
  547.                 NodeAction := action;
  548.             end;
  549.     end;
  550.  
  551.     procedure RestoreNodeAction;
  552.     begin
  553.         with nodeGlobs^ do
  554.             begin
  555.                 NodeAction := savedNodeAction[1];
  556.                 savedNodeAction[1] := savedNodeAction[2];
  557.                 savedNodeAction[2] := savedNodeAction[3];
  558.                 savedNodeAction[3] := savedNodeAction[4];
  559.                 savedNodeAction[4] := None;
  560.             end;
  561.     end;
  562.  
  563.     procedure Error (fatal: boolean; str: string);
  564.         var
  565.             dItem: integer;
  566.     begin
  567.         ParamText(str, '', '', '');
  568.         if fatal then
  569.             dItem := StopAlert(141, nil)
  570.         else
  571.             dItem := CautionAlert(141, nil);
  572.     end;
  573.  
  574.     function Sure (str: string): boolean;
  575.     begin
  576.         ParamText(str, '', '', '');
  577.         Sure := StopAlert(142, nil) = 2;
  578.     end;
  579.  
  580.     procedure DumpHand (hand: handle);
  581.         var
  582.             wind: windowPtr;
  583.             r: rect;
  584.             event: EventRecord;
  585.     begin
  586. {$IFC MWerks}
  587.         r := qd.screenBits.bounds;
  588. {$ELSEC}
  589.         r := screenBits.bounds;
  590. {$ENDC}
  591.         InsetRect(r, 50, 50);
  592.         wind := NewWindow(nil, r, 'Dump', true, 4, windowPtr(-1), true, 0);
  593.         SetPort(wind);
  594.         TextFont(Geneva);
  595.         TextSize(9);
  596. {$IFC MWERKS}
  597.         TETextBox(hand^, GetHandleSize(hand), wind^.portRect, teJustLeft);
  598. {$ELSEC}
  599.         TextBox(hand^, GetHandleSize(hand), wind^.portRect, teJustLeft);
  600. {$ENDC}
  601.         repeat
  602.         until GetOSEvent(everyEvent, event);
  603.         DisposeWindow(wind);
  604.     end;
  605. end.